﻿<ion-view hide-nav-bar="{{$root.dingMobile.hideHeader}}" view-title="待办任务">
    <ion-nav-bar class="bar-calm">
        <ion-nav-buttons side="left">
            <button class="button button-icon button-clear ion-navicon" menu-toggle="left"></button>
        </ion-nav-buttons>
    </ion-nav-bar>

    <div class="bar {{$root.dingMobile.dingHeaderClass}}  item-input-inset">
        <label class="item-input-wrapper"
               ng-class="{'placeholder-icon-focus':focus,'placeholder-icon-unfocus':!focus}"
               style="transition: all linear 0.1s;">
            <i class="icon ion-ios-search-strong"></i>
            <input type="search" placeholder="搜索"
                   class="input-placeholder"
                   ng-model="searchKey" ng-change="doSearch()"
                   ng-focus="focus=true" ng-blur="searchKey==''?focus=false:focus=true">
            <i class="icon ion-close-circled placeholder-icon" style="vertical-align: middle;"
               on-tap="clearSearch()" ng-if="searchKey.length"></i>
        </label>
    </div>
    <div class="ng-hide animated fadeIn scrollTop" ng-show="displayTop" ng-click="scrollTop()">
        <i class="icon ion-arrow-up-a"></i>
    </div>
    <ion-content class="scroll-content ionic-scroll {{$root.dingMobile.dingSubHeaderClass}} has-tabs" on-scroll="getScrollPosition();">
        <ion-refresher on-refresh="refreshUnfinishedWorkItem()">
        </ion-refresher>
        
        <ion-item ng-repeat="workitem in unfinishedWorkItems | orderBy:['-Priority','-ReceiveTime']" class="circle-item"
                  ng-click="openWorkItem('{{workitem.ObjectID}}')">
            <div class="circle-left">
                <i class="circle-name"
                   ng-class="{'user-a':$index%4==0,'user-b':$index%4==1,'user-c':$index%4==2,'user-d':$index%4==3,'circle-name-select':selectItemMode}">
                    <span>{{workitem.OrigiantorName|limitTo :-2}}</span>
                </i>
            </div>
            <div class="circle-center" ng-class="{'circle-center-select':selectItemMode}">
                <div class="item-content">
                    <h2>
                        <i ng-if="workitem.Priority=='2'" class="icon-urgent"></i>{{workitem.InstanceName}}
                    </h2>
                    <p>
                        <label>
                            {{workitem.OrigiantorOUName}}-{{workitem.OrigiantorName}} 发起
                        </label>
                        <label style="float:right;">
                            {{workitem.ReceiveTime|limitTo:-16}}
                        </label>
                    </p>
                </div>
            </div>
        </ion-item>

        <ion-item ng-if="unfinishedWorkItems.length > 0 && loadCompleted"
                  style="cursor:pointer">
            <div class="item-icon-left" style="padding-left:20px;">
                <i class="icon ion-android-happy"></i>
                <h2>全部加载完成</h2>
            </div>
        </ion-item>
        <ion-item ng-if="unfinishedWorkItems.length == 0 && loadCompleted && searchKey=='' && !exception"
                  style="cursor:pointer">
            <div class="item-icon-left" style="padding-left:20px;">
                <i class="icon ion-checkmark"></i>
                <h2>您的待办已经全部处理完成</h2>
            </div>
        </ion-item>
        <ion-item ng-if="unfinishedWorkItems.length == 0 && loadCompleted && searchKey!='' && !exception"
                  style="cursor:pointer">
            <div class="item-icon-left" style="padding-left:20px;">
                <i class="icon ion-information-circled"></i>
                <h2>未搜索到任务</h2>
            </div>
        </ion-item>
        <ion-item ng-if="exception"
                  style="cursor:pointer">
            <div class="item-icon-left" style="padding-left:20px;">
                <i class="icon ion-information-circled"></i>
                <h2>系统数据加载失败，请稍候再试！</h2>
            </div>
        </ion-item>
        <ion-infinite-scroll ng-if="!loadCompleted"
                             icon="ion-loading-c"
                             distance="10%"
                             on-infinite="loadMoreUnfishedWorkItem()">
        </ion-infinite-scroll>
    </ion-content>
</ion-view>